import Page
from Page import Motorcade
from Base.Base import Base
from selenium.webdriver.common.by import By


class MotorcadeIndexPage(Base):
    """
    车队首页-首页页面
    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 左侧的home键
        self.motorcade_home_btn = (By.XPATH, Motorcade.RESOURCE_ID.format("ivHome"))

        # 左侧的返回键
        self.motorcade_back_btn = (By.XPATH, Motorcade.RESOURCE_ID.format('ivBack'))

        # 首页图标
        self.motorcade_index_car_img = (By.XPATH, Motorcade.motorcade_index_icon.format(""))

        # 首页提示
        self.motorcade_index_tip_text = (By.XPATH, Motorcade.motorcade_index_tip_text.format(""))

        # 加入车队按钮
        self.motorcade_index_add_car_btn = (By.XPATH, Motorcade.RESOURCE_ID.format("btn_join_motorcade"))

        # 创建车队按钮
        self.motorcade_index_create_car_btn = (By.XPATH, Motorcade.RESOURCE_ID.format("btn_create_motorcade"))

        # 加入车队标题
        self.motorcade_index_add_car_title_text = (By.XPATH, Motorcade.RESOURCE_ID.format("title"))

        # 加入车队输入框
        self.motorcade_index_add_input = (By.XPATH, Motorcade.RESOURCE_ID.format("blt_name_et"))

        # 确认按钮
        self.motorcade_index_ok_btn = (By.XPATH, Motorcade.RESOURCE_ID.format("confirm"))

        # 取消按钮
        self.motorcade_index_no_btn = (By.XPATH, Motorcade.RESOURCE_ID.format("cancel"))

        # 创建车队标题
        self.motorcade_index_create_car_title_text = (By.XPATH, Motorcade.RESOURCE_ID.format("title"))

        # 创建车队输入框
        self.motorcade_index_create_input = (By.XPATH, Motorcade.RESOURCE_ID.format("blt_name_et"))

        # 确认按钮
        self.motorcade_index_create_ok_btn = (By.XPATH, Motorcade.RESOURCE_ID.format("confirm"))

        # 取消按钮
        self.motorcade_index_create_no_btn = (By.XPATH, Motorcade.RESOURCE_ID.format("cancel"))

    def click_home(self):
        """
        点击左侧的home键

        :return:None
        """
        self.click_element(self.motorcade_home_btn)

    def click_back(self):
        """
        点击左侧的back键

        :return:None
        """
        self.click_element(self.motorcade_back_btn)

    def get_index_car(self, index=1):
        """
        获取首页图标

        :return:获取元素
        """
        self.motorcade_index_car_img = (By.XPATH, Motorcade.motorcade_index_icon.format(index))
        return self.find_element_o(self.motorcade_index_car_img)

    def get_index_tip(self, index=1):
        """
        获取首页提示

        :return:获取元素
        """
        self.motorcade_index_tip_text = (By.XPATH, Motorcade.motorcade_index_tip_text.format(index))
        return self.find_element_o(self.motorcade_index_tip_text)

    def click_index_add_car(self):
        """
        点击加入车队按钮

        :return:获取元素
        """
        self.click_element(self.motorcade_index_add_car_btn)

    def click_index_create_car(self):
        """
        点击创建车队按钮

        :return:None
        """
        self.click_element(self.motorcade_index_create_car_btn)

    def get_index_add_car_title(self):
        """
        获取加入车队标题

        :return:获取元素
        """
        return self.find_element_o(self.motorcade_index_add_car_title_text)

    def input_index_add(self, index):
        """
        输入加入车队内容

        index为输入车队的名称
        :return:None
        """
        self.input_text(self.motorcade_index_add_input, index)

    def click_index_ok(self):
        """
        点击确认按钮

        :return:None
        """
        self.click_element(self.motorcade_index_ok_btn)

    def click_index_no(self):
        """
        点击取消按钮

        :return:None
        """
        self.click_element(self.motorcade_index_no_btn)

    def is_display_motorcade_add_car(self):
        """
        是否进入加入车队界面

        :return: bool
        """
        return self.is_display(self.motorcade_index_add_car_title_text)

    def get_index_create_car_title(self):
        """
        获取创建车队标题

        :return:获取元素
        """
        return self.find_element_o(self.motorcade_index_create_car_title_text)

    def input_index_create(self, index):
        """
        输入创建车队内容

        index为输入车队的名称
        :return:None
        """
        self.input_text(self.motorcade_index_create_input, index)

    def click_index_create_ok(self):
        """
        点击创建确认按钮

        :return:None
        """
        self.click_element(self.motorcade_index_create_ok_btn)

    def click_index_create_no(self):
        """
        点击创建取消按钮

        :return:None
        """
        self.click_element(self.motorcade_index_create_no_btn)

    def is_display_motorcade_create_car(self):
        """
        是否进入加入车队界面

        :return: bool
        """
        return self.is_display(self.motorcade_index_create_car_title_text)

    def is_display_motorcade_index(self):
        """
        是否进入首页

        :return: bool
        """
        return self.is_display(self.motorcade_index_add_car_btn)

    def is_toast_motorcade_toast(self, index):
        """
        是否出现提示创建成功提示

        index 为弹窗提示语
        :return: bool
        """
        return self.is_toast_exist(index)


if __name__ == '__main__':
    pass
